package engine
{
	import ash.core.Engine;
	import ash.tick.FrameTickProvider;
	
	import engine.managers.GroupManager;
	import engine.managers.FileManager;
	import engine.managers.ScreenManager;
	import engine.utils.Key;
	import engine.utils.Mouse;
	
	import flash.display.Sprite;

	public class GameEngine
	{
		private static var _systemManager:Engine 		= new Engine();
		private static var _fileManager:FileManager 	= new FileManager();
		private static var _groupManager:GroupManager 	= new GroupManager();
		private static var _screenManager:ScreenManager;
		private static var _tickProvider:FrameTickProvider;
		
		public function GameEngine()
		{
			throw new Error("Game Engine :: constructor() :: Do not instantiate!");
		}
		
		public static function construct(gameContainer:Sprite):void
		{
			_screenManager = new ScreenManager(gameContainer);
			
			_tickProvider = new FrameTickProvider(_screenManager.stage, 1);
			_tickProvider.add(_systemManager.update);
			_tickProvider.start();
			
			//These will get phased out later.
			Key.construct();
			Mouse.construct();
		}
		
		public static function get tickProvider():FrameTickProvider { return _tickProvider; }
		public static function get systemManager():Engine 			{ return _systemManager; }
		public static function get fileManager():FileManager 		{ return _fileManager; }
		public static function get screenManager():ScreenManager	{ return _screenManager; }
		public static function get groupManager():GroupManager		{ return _groupManager; }
	}
}